<form action="{:url('admin/product/typeSort')}" method="post">
	<div>
		{volist name="list" id="vo"}
			<p>
				{$vo.name} <input type="hidden" name="id[]" value="{$vo.id}"> 
				<a href="{:url('admin/product/editType',array('id'=>$vo['id']))}">编辑</a>
				<a href="{:url('admin/product/deleteType',array('id'=>$vo['id']))}">删除</a>
				<input type="text" name="order[]" value="{$vo.orderNo}">
			</p>
		{/volist}
	</div>
	<input type="submit" value="排序">
</form>

<form id="form_type_new" action="{:url('admin/product/addTypeSave')}" method="post">
	名称<input type="text" name="name">  <input type="text" name="orderNo" placeholder="排序，输入数字">
	<p><input type="button" id="btn_newType" value="提交"></p>
</form>
<input type="button" onclick="custom_close()" value="关闭">
<script src="/public__STATIC__/assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script>
	function custom_close(){   //关闭当前窗口
		if(confirm("您确定要关闭本页吗？")){
			window.opener=null;
			window.open('','_self');
			window.close();
		}
		else{}
	}

	//新增分类
	$("#btn_newType").click(function() {
        var name = $("#form_type_new input[name='name']").val();
		var order = $("#form_type_new input[name='orderNo']").val();
		var param = {"name": name,"orderNo":order};
		var type_url = "{:url('admin/product/addTypeSave')}";
		$.ajax({
            url: type_url,
            type: "POST",
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(param),
        }).done(function(data) {
            if(data.status === '1') {
                alert('添加成功');
                location.reload();
            } else if(data.status === '2') {
                alert('添加失败，请重试');
                location.reload();
            }
        })
	});
</script>